package com.chenss.dragonserapp.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chenss.dragonserapp.R;
import com.chenss.dragonserapp.base.BaseAdp;
import com.chenss.dragonserapp.model.GoodsListModel;

import java.util.List;

public class GoodsListAdapter extends BaseAdp<GoodsListModel> {
String type="1";

	public void setType(String type) {
		this.type = type;
	}

	public GoodsListAdapter(Context ctx, List<GoodsListModel> list,String tp) {
		super(ctx, list, R.layout.item_frag_goods);
		type=tp;
	}

	@Override
	public void Convert(final int position, View convertView) {
		// TODO Auto-generated method stub
// 1.库存
// 2.销量
		TextView tv_state = Get(convertView,R.id.tv_count);
		ImageView img = Get(convertView,R.id.img);
		TextView tv_name = Get(convertView,R.id.tv_name);
		tv_name.setText( mDataList.get(position).getName()+"("+mDataList.get(position).getProperty_related()+")");
		if(!TextUtils.isEmpty(mDataList.get(position).getImage_default()))
			Glide.with(mContext).load(mDataList.get(position).getImage_default()).asBitmap().placeholder(R.mipmap.morentu).into(img);

		final int status=Integer.parseInt(type);
		switch (status){
			case 1:
				tv_state.setText("库存："+ mDataList.get(position).getStock());
				break;
			case 2:
				tv_state.setText("销量："+ mDataList.get(position).getSales());
				break;

		}

	} 
}
